package ar.edu.utn.frsf.tpae.a2012.g05.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

@Entity
@Table(name = "mov_pag")
public class Pago extends Movimiento {

	@Column(name = "mov_pag_cod", nullable = false)
	private String codigo;

	@Column(name = "mov_pag_usr_cmt", length = 48, nullable = false)
	private String comentario;
	
	public Pago() {
		super();
		this.setTipo("Pago");		
	}

	public String getCodigo() {
		return codigo;
	}

	public void setCodigo(String codigo) {
		this.codigo = codigo;
	}

	public String getComentario() {
		return comentario;
	}

	public void setComentario(String comentario) {
		this.comentario = comentario;
	}

	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}

	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}
	
	public int hashCode2() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((codigo == null) ? 0 : codigo.hashCode());
		result = prime * result
				+ ((comentario == null) ? 0 : comentario.hashCode());
		return result;
	}

	public boolean equals2(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Pago other = (Pago) obj;
		if (codigo == null) {
			if (other.codigo != null)
				return false;
		} else if (!codigo.equals(other.codigo))
			return false;
		if (comentario == null) {
			if (other.comentario != null)
				return false;
		} else if (!comentario.equals(other.comentario))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Pago [codigo=" + codigo + ", comentario=" + comentario
				+ ", id=" + id + ", fecha=" + fecha
				+ ", monto=" + monto + "]";
	}

}